package org.csmzxy.class2334;

public class Example08 {
    public static void add() {
        StringBuffer s = new StringBuffer();
        s.append("itheima");
        System.out.println("在末尾添加字符串的结果:" + s);
        s.insert(2, "cast");
        System.out.println("第3个位置插入字符串的结果:" + s);
    }
    public static void modify() {
        StringBuffer s = new StringBuffer("itheima");
        s.setCharAt(1, 's');
        System.out.println("修改第2个字符的结果:" + s);
        s.replace(2, 7, "cast");
        System.out.println("替换第3个到第7个字符的结果:" + s);
        s.reverse();
        System.out.println("反转字符串s的结果:" + s);
    }
        public static void delete() {
            StringBuffer s = new StringBuffer("itheima");
            s.deleteCharAt(1);
            System.out.println("删除第2个字符的结果:" + s);
            s.delete(0, 1);
            System.out.println("删除第1个到第2个字符的结果:" + s);
    }
    public static void main(String[] args){
        System.out.println("1.添加操作-------------");
        add ();
        System.out.println("2.修改操作-------------");
        modify ();
        System.out.println("3.删除操作-------------");
        delete ();
    }
}
